﻿<!DOCTYPE html>
<html>
<head>
    <title>Gameschool</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
    <script type="text/javascript">
        var username = document.cookie.substring(14, document.cookie.indexOf("&"));        
    </script>
</head>
<body>
    <div class="page">
        <div id="header">
            <a href="http://localhost:23973/">
                <img class="headerImg" src="../../content/themes/base/images/GS2.png" alt="Its a dinosaur eating a sign" align="left" /></a>
            <p class="header">
                Velkomin/n
                <script type="text/javascript">  document.write(username)</script>  - @Html.ActionLink("Skrá út", "logOff", "Account")</p>
        </div>
        <div id="leftSidebar">
            <p class="frontLeft">@Html.ActionLink("Forsíða", "CourseView", "Course")</p>
            <p class="frontLeft">@Html.ActionLink("Stundatafla", "timetable", "Home")</p>
            <p class="frontLeft">@Html.ActionLink("Verkefni", "assignments", "Home")</p>
            <p class="frontLeft">@Html.ActionLink("Mín Síða", "profile", "Home")</p>
            <p class="frontLeft">@Html.ActionLink("Próf", "exams", "Home")</p>
            <p class="frontLeft">
                <a class="frontLeftLink" href="http://www.hr.is" target="_blank">HR.is</a></p>
        </div>
        <div id="rightSidebar">

    <!--comment glugginn í sidebar virkni hlaðið inn í $(document).ready-->
            <ul class="commentList">        
		        <li class="commentAdd" id="commentAdd">
                    <input type="hidden" id="LastVisited" value="@DateTime.Now" />
			        <textarea id="CommentText" name="CommentText" rows="3" cols="20"></textarea>
			        <label>
				        <button id="btnAddComment">Add comment</button>
			        </label>
			        @Html.ValidationMessage( "CommentText" )
		        </li>
	        </ul>

        </div>

  <!--MENUCONTAINER-->
        <div id="menuContainer">
            <ul id="menu">
                <li>@Html.ActionLink("Stig", "stats", "Home")</li>
                <li>@Html.ActionLink("Verslun", "shop", "Home")</li>
            </ul>
        </div>
        <div id="content">
            @RenderBody()
            <div class="push">
            </div>
        </div>
    </div>

<!--CommentTemplate-->
    <script id="commentTemplate" type="text/html">
	<li>
		<a href="http://www.ru.is"><img src='@Url.Content("~/Images/User.png")' alt="User" /></a>
		<div class="commentBody">
			<a href="http://www.ru.is">${UserName}</a>
			<span>${commentText}</span>
			<div>
				<button class="likeButton" value="${commentID}" >Like this</button>
                <button class="deleteButton" value="${commentID}">Delete comment</button>
			</div>
		</div>
	</li>
    </script>


    <script type="text/javascript">
        function loadComments(){
                var navString = $("#navString").val();
                var ID = $("#ID").val();
                var param = {navString : navString, ID : ID}
                $.getJSON("/Comment/loadComments", param,function(data){
                    $("#commentTemplate").tmpl(data).insertAfter($('.commentAdd'));
                });
            }
        $(document).ready(function () {
            var isAdmin = @Request.Cookies["userInfo"].Values["isAdmin"];
            if (isAdmin == 1) {
                //$('.leftSideBar').append('<p class=\"frontLeft\"><a href=\"manage\" >Umsjón</a></p>');
                $('<p class=\"frontLeft\">@Html.ActionLink("Umsjón", "admin", "account")</p>').insertAfter($('.frontLeftLink').parent());
            }
            $("#btnAddComment").live("click",function(){
                var navString = $("#navString").val();
                var ID = $("#ID").val();
                var commentText = $("textarea#CommentText").val();
                var param = { navString: navString, ID: ID, commentText:commentText}
                if(commentText!=""){
                    $.getJSON("/Comment/addComment", param, function(data){
                        $("#commentTemplate").tmpl(data).insertAfter($('.commentAdd'));
                        $("textarea#CommentText").val("");
                    });
                }
             });
             $(".deleteButton").live("click",function(){
                var commentID = $(this).val();  
                var param = {commentID:commentID}
                $.getJSON("/Comment/removeComment",param,function(data){
                    if(data==true){((($(this).parent()).parent()).parent()).remove();}
                    });
                    });


            loadComments();
            loadExamEventHandlers();
        });
    </script>
    <!--document.ready-->
</body>
</html>
